<%@page import="com.libra.assemble.xutil.enums.RoleType" %>
<%@page import="com.libra.assemble.xutil.enums.Whether" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<c:set var="roleType_admin" value="<%=RoleType.ADMIN %>"/>
<c:set var="roleType_user" value="<%=RoleType.USER %>"/>
<c:set var="default_yes" value="<%=Whether.YES %>"/>
<c:set var="default_not" value="<%=Whether.NOT %>"/>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <title>角色管理</title>
  <link href="${ctx}/static/support/icheck-1.0.2/skins/flat/blue.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
  <!-- 路径导航 -->
  <ol class="breadcrumb">
    <li><a href="${ctx}/workbench">主页</a></li>
    <li><a href="${ctx}/role">角色管理</a></li>
    <li class="active">
      <c:if test="${action eq 'create'}">添加角色</c:if>
      <c:if test="${action eq 'update'}">修改角色</c:if>
    </li>
  </ol>
  <!-- /路径导航 -->

  <div class="panel panel-default">
    <div class="panel-heading">
      <h3 class="panel-title">
        <c:if test="${action eq 'create'}">添加角色</c:if>
        <c:if test="${action eq 'update'}">修改角色</c:if>
      </h3>
    </div>

    <div class="panel-body">
      <form class="form-horizontal" id="role-form" action="${ctx}/role/${action}" method="post" role="form">
        <input type="hidden" id="role-id" name="id" value="${role.id}">

        <div class="form-group">
          <label for="role-name" class="col-sm-2 control-label">角色名称</label>

          <div class="col-sm-10">
            <input type="text" class="form-control" id="role-name" name="name" value="${role.name}" placeholder="角色名称">
          </div>
        </div>

        <div class="form-group">
          <label for="role-name" class="col-sm-2 control-label">角色代码</label>

          <div class="col-sm-10">
            <input type="text" class="form-control" id="role-code" name="code" value="${role.code}" placeholder="角色代码">
          </div>
        </div>

        <div class="form-group">
          <label for="role-name" class="col-sm-2 control-label">角色类型</label>

          <div class="col-sm-10">
            <label class="radio-inline" style="padding-left: 0px;">
              <input type="radio" name="roleType" value="${roleType_admin}" <c:if test="${role.roleType eq roleType_admin}">checked="checked"</c:if>>
              <span style="margin-left: 0px; vertical-align: middle;">${roleType_admin.value}</span>
            </label>
            <label class="radio-inline" style="padding-left: 0px;">
              <input type="radio" name="roleType" value="${roleType_user}" <c:if test="${role.roleType ne roleType_admin}">checked="checked"</c:if>>
              <span style="margin-left: 0px; vertical-align: middle;">${roleType_user.value}</span>
            </label>
          </div>
        </div>

        <div class="form-group">
          <label for="role-name" class="col-sm-2 control-label">是否默认角色</label>

          <div class="col-sm-10">
            <label class="radio-inline" style="padding-left: 0px;">
              <input type="radio" name="defaultRole" class="uniform" value="${default_yes}" <c:if test="${role.defaultRole eq default_yes}">checked="checked"</c:if>>
              <span style="margin-left: 0px; vertical-align: middle;">${default_yes.value}</span>
            </label>
            <label class="radio-inline" style="padding-left: 0px;">
              <input type="radio" name="defaultRole" class="uniform" value="${default_not}" <c:if test="${role.defaultRole ne default_yes}">checked="checked"</c:if>>
              <span style="margin-left: 0px; vertical-align: middle;">${default_not.value}</span>
            </label>
          </div>
        </div>

        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-default" onclick="return confirm('是否提交上面的信息？')"> 提 交</button>
            <button type="button" class="btn btn-default" onclick="history.back()"> 返 回</button>
          </div>
        </div>
      </form>
    </div>

  </div>

</div>

<!-- 以下开始 加载JS动态效果 -->

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="${ctx}/static/jquery/jquery-1.11.3.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="${ctx}/static/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>

<!-- 增强复选框和单选框 -->
<script src="${ctx}/static/support/icheck-1.0.2/icheck.min.js"></script>

<script type="text/javascript">
  jQuery(document).ready(function () {
    $(':radio').iCheck({
      radioClass: 'iradio_flat-blue'
    });
  });
</script>
</body>
</html>